package org.carota.cret;

import java.math.BigInteger;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Date;

/**
 * @author : AnWen
 * @version :1.0
 * @since : 2023-03-22 15:18
 */


public interface X509Dao {
    /**
     * 制作证书
     *
     *
     * @param issuer       发布者
     * @param subject       主体
     * @param notBefore    使用日期
     * @param notAfter     到期
     * @param certDestPath 生成证书地址
     * @param serial       证书序列号
     * @param keyPassword  证书密码
     * @param alias        证书别名
     * @throws Exception
     */
    void createCert(String issuer, String subject, Date notBefore, Date notAfter, String certDestPath, BigInteger serial,
                    String keyPassword, String alias) throws Exception;

    /**
     * 输出证书信息
     *
     * @param certPath    证书地址
     * @param keyPassword 证书密码
     * @throws Exception
     */
    void printCert(String certPath, String keyPassword) throws Exception;

    /**
     * 返回公钥
     *
     * @param certPath
     * @param keyPassword
     * @throws Exception
     */
    PublicKey getPublicKey(String certPath, String keyPassword) throws Exception;

    /**
     * 返回私钥
     *
     * @param certPath
     * @param keyPassword
     * @throws Exception
     */
    PrivateKey getPrivateKey(String certPath, String keyPassword) throws Exception;

    /**
     * 证书延期(未实现)
     *
     * @param endTime
     * @param certPath
     * @param keyPassword
     * @throws Exception
     */
    void certDelayTo(Date endTime, String certPath, String keyPassword) throws Exception;

    /**
     * 修改密码
     *
     * @param certPath
     * @param oldPwd
     * @param newPwd
     * @throws Exception
     */
    void changePassword(String certPath, String oldPwd, String newPwd) throws Exception;

    /**
     * 删除证书
     *
     * @param certPath
     * @param keyPassword
     * @param alias
     * @param entry
     * @throws Exception
     */
    void deleteAlias(String certPath, String keyPassword, String alias, String entry) throws Exception;

}
